import 'package:boss/provider/commodity_provider.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/costManagement/widget/cost_management_list.dart';
import 'package:boss/ui/widget/search_bar.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class CostManagementBrowser extends StatefulWidget {
  @override
  _State createState() => _State();
}

class _State extends State<CostManagementBrowser> {

  String cancelButtonText='';
  bool get cancelButtonBool{
      return cancelButtonText.toString().trim()==''?true:false;
  }

  TextEditingController _controller =  TextEditingController();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

  }


  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Consumer<CommodityProvider>(
      builder:(context,commodityProvider,_){
        return Column(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.symmetric(
                horizontal: 30.w,
                vertical: 30.w,
              ),
              child:Row(
                children: <Widget>[
                  Expanded(
                    child: SearchBar(
                        controller:_controller,
                        hintText: '请输入需要查询的菜品名称',
                        onChanged:(e){


                          cancelButtonText=e;
                          setState(() {});
                        }
                    ),
                  ),
                  cancelButtonBool==true?Container():GestureDetector(
                      onTap:(){
                        cancelButtonText='';
                        _controller.text='';
                        setState(() {});
                      },
                      child: Padding(
                        padding:EdgeInsets.only(
                          left:10.w,
                        ),
                        child: Center(child: Text("取消",
                          style: TextStyleConstant().normal_2_26,
                        )),
                      )
                  ),
                ],
              ),
            ),
            CostManagementList(commodityProvider:commodityProvider,cancelButtonText:cancelButtonText),
          ],
        );
      },
    );

  }
}



